namespace GameSchool.Migrations
{
    using System.Data.Entity.Migrations;
    
    public partial class doddi444 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("StudentCourses", "Student_studentID", "Students");
            DropForeignKey("StudentCourses", "Course_courseID", "Courses");
            DropForeignKey("CourseAchievements", "Course_courseID", "Courses");
            DropForeignKey("CourseAchievements", "Achievement_achievementID", "Achievements");
            DropIndex("StudentCourses", new[] { "Student_studentID" });
            DropIndex("StudentCourses", new[] { "Course_courseID" });
            DropIndex("CourseAchievements", new[] { "Course_courseID" });
            DropIndex("CourseAchievements", new[] { "Achievement_achievementID" });
            CreateTable(
                "StudentAssignments",
                c => new
                    {
                        studentID = c.Int(nullable: false),
                        assignmentID = c.Int(nullable: false),
                        student_studentID = c.Int(),
                        assignment_assignmentID = c.Int(),
                    })
                .PrimaryKey(t => new { t.studentID, t.assignmentID })
                .ForeignKey("Students", t => t.student_studentID)
                .ForeignKey("Assignments", t => t.assignment_assignmentID)
                .ForeignKey("Assignments", t => t.assignmentID, cascadeDelete: true)
                .ForeignKey("Students", t => t.studentID, cascadeDelete: true)
                .Index(t => t.student_studentID)
                .Index(t => t.assignment_assignmentID)
                .Index(t => t.assignmentID)
                .Index(t => t.studentID);
            
            CreateTable(
                "StudentExams",
                c => new
                    {
                        studentID = c.Int(nullable: false),
                        examID = c.Int(nullable: false),
                        student_studentID = c.Int(),
                        exam_examID = c.Int(),
                    })
                .PrimaryKey(t => new { t.studentID, t.examID })
                .ForeignKey("Students", t => t.student_studentID)
                .ForeignKey("Exams", t => t.exam_examID)
                .ForeignKey("Exams", t => t.examID, cascadeDelete: true)
                .ForeignKey("Students", t => t.studentID, cascadeDelete: true)
                .Index(t => t.student_studentID)
                .Index(t => t.exam_examID)
                .Index(t => t.examID)
                .Index(t => t.studentID);
            
            CreateTable(
                "StudentLevels",
                c => new
                    {
                        studentID = c.Int(nullable: false),
                        levelID = c.Int(nullable: false),
                        student_studentID = c.Int(),
                        level_levelID = c.Int(),
                    })
                .PrimaryKey(t => new { t.studentID, t.levelID })
                .ForeignKey("Students", t => t.student_studentID)
                .ForeignKey("Levels", t => t.level_levelID)
                .ForeignKey("Levels", t => t.levelID, cascadeDelete: true)
                .ForeignKey("Students", t => t.studentID, cascadeDelete: true)
                .Index(t => t.student_studentID)
                .Index(t => t.level_levelID)
                .Index(t => t.levelID)
                .Index(t => t.studentID);
            
            CreateTable(
                "StudentLectures",
                c => new
                    {
                        studentID = c.Int(nullable: false),
                        lectureID = c.Int(nullable: false),
                        student_studentID = c.Int(),
                        lecture_lectureID = c.Int(),
                    })
                .PrimaryKey(t => new { t.studentID, t.lectureID })
                .ForeignKey("Students", t => t.student_studentID)
                .ForeignKey("Lectures", t => t.lecture_lectureID)
                .ForeignKey("Lectures", t => t.lectureID, cascadeDelete: true)
                .ForeignKey("Students", t => t.studentID, cascadeDelete: true)
                .Index(t => t.student_studentID)
                .Index(t => t.lecture_lectureID)
                .Index(t => t.lectureID)
                .Index(t => t.studentID);
            
            CreateTable(
                "AchievementCourseStudents",
                c => new
                    {
                        achievementID = c.Int(nullable: false),
                        courseID = c.Int(nullable: false),
                        studentID = c.Int(nullable: false),
                        achievement_achievementID = c.Int(),
                        course_courseID = c.Int(),
                        student_studentID = c.Int(),
                    })
                .PrimaryKey(t => new { t.achievementID, t.courseID, t.studentID })
                .ForeignKey("Achievements", t => t.achievement_achievementID)
                .ForeignKey("Courses", t => t.course_courseID)
                .ForeignKey("Students", t => t.student_studentID)
                .ForeignKey("Students", t => t.studentID, cascadeDelete: true)
                .ForeignKey("Courses", t => t.courseID, cascadeDelete: true)
                .ForeignKey("Achievements", t => t.achievementID, cascadeDelete: true)
                .Index(t => t.achievement_achievementID)
                .Index(t => t.course_courseID)
                .Index(t => t.student_studentID)
                .Index(t => t.studentID)
                .Index(t => t.courseID)
                .Index(t => t.achievementID);
            
            CreateTable(
                "StudentCourse1",
                c => new
                    {
                        Student_studentID = c.Int(nullable: false),
                        Course_courseID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Student_studentID, t.Course_courseID })
                .ForeignKey("Students", t => t.Student_studentID, cascadeDelete: true)
                .ForeignKey("Courses", t => t.Course_courseID, cascadeDelete: true)
                .Index(t => t.Student_studentID)
                .Index(t => t.Course_courseID);
            
            CreateTable(
                "CourseAchievement1",
                c => new
                    {
                        Course_courseID = c.Int(nullable: false),
                        Achievement_achievementID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Course_courseID, t.Achievement_achievementID })
                .ForeignKey("Courses", t => t.Course_courseID, cascadeDelete: true)
                .ForeignKey("Achievements", t => t.Achievement_achievementID, cascadeDelete: true)
                .Index(t => t.Course_courseID)
                .Index(t => t.Achievement_achievementID);
            
            AddColumn("Teachers", "selected", c => c.Boolean(nullable: false));
            AddColumn("Teachers", "userNameID", c => c.Guid(nullable: false));
            AddColumn("Courses", "numStudents", c => c.Int(nullable: false));
            AddColumn("Courses", "numTeachers", c => c.Int(nullable: false));
            AddColumn("StudentCourses", "studentID", c => c.Int(nullable: false));
            AddColumn("StudentCourses", "courseID", c => c.Int(nullable: false));
            AddColumn("StudentCourses", "studentXP", c => c.Int(nullable: false));
            AddColumn("CourseAchievements", "courseID", c => c.Int(nullable: false));
            AddColumn("CourseAchievements", "achievementID", c => c.Int(nullable: false));
            AlterColumn("StudentCourses", "student_studentID", c => c.Int());
            AlterColumn("StudentCourses", "course_courseID", c => c.Int());
            AlterColumn("CourseAchievements", "course_courseID", c => c.Int());
            AlterColumn("CourseAchievements", "achievement_achievementID", c => c.Int());
            DropPrimaryKey("StudentCourses", new[] { "Student_studentID", "Course_courseID" });
            AddPrimaryKey("StudentCourses", new[] { "studentID", "courseID" });
            DropPrimaryKey("CourseAchievements", new[] { "Course_courseID", "Achievement_achievementID" });
            AddPrimaryKey("CourseAchievements", new[] { "courseID", "achievementID" });
            AddForeignKey("StudentCourses", "student_studentID", "Students", "studentID");
            AddForeignKey("StudentCourses", "course_courseID", "Courses", "courseID");
            AddForeignKey("StudentCourses", "studentID", "Students", "studentID", cascadeDelete: true);
            AddForeignKey("StudentCourses", "courseID", "Courses", "courseID", cascadeDelete: true);
            AddForeignKey("CourseAchievements", "course_courseID", "Courses", "courseID");
            AddForeignKey("CourseAchievements", "achievement_achievementID", "Achievements", "achievementID");
            AddForeignKey("CourseAchievements", "courseID", "Courses", "courseID", cascadeDelete: true);
            AddForeignKey("CourseAchievements", "achievementID", "Achievements", "achievementID", cascadeDelete: true);
            CreateIndex("StudentCourses", "student_studentID");
            CreateIndex("StudentCourses", "course_courseID");
            CreateIndex("StudentCourses", "studentID");
            CreateIndex("StudentCourses", "courseID");
            CreateIndex("CourseAchievements", "course_courseID");
            CreateIndex("CourseAchievements", "achievement_achievementID");
            CreateIndex("CourseAchievements", "courseID");
            CreateIndex("CourseAchievements", "achievementID");
        }
        
        public override void Down()
        {
            DropIndex("CourseAchievement1", new[] { "Achievement_achievementID" });
            DropIndex("CourseAchievement1", new[] { "Course_courseID" });
            DropIndex("StudentCourse1", new[] { "Course_courseID" });
            DropIndex("StudentCourse1", new[] { "Student_studentID" });
            DropIndex("CourseAchievements", new[] { "achievementID" });
            DropIndex("CourseAchievements", new[] { "courseID" });
            DropIndex("CourseAchievements", new[] { "achievement_achievementID" });
            DropIndex("CourseAchievements", new[] { "course_courseID" });
            DropIndex("AchievementCourseStudents", new[] { "achievementID" });
            DropIndex("AchievementCourseStudents", new[] { "courseID" });
            DropIndex("AchievementCourseStudents", new[] { "studentID" });
            DropIndex("AchievementCourseStudents", new[] { "student_studentID" });
            DropIndex("AchievementCourseStudents", new[] { "course_courseID" });
            DropIndex("AchievementCourseStudents", new[] { "achievement_achievementID" });
            DropIndex("StudentCourses", new[] { "courseID" });
            DropIndex("StudentCourses", new[] { "studentID" });
            DropIndex("StudentCourses", new[] { "course_courseID" });
            DropIndex("StudentCourses", new[] { "student_studentID" });
            DropIndex("StudentLectures", new[] { "studentID" });
            DropIndex("StudentLectures", new[] { "lectureID" });
            DropIndex("StudentLectures", new[] { "lecture_lectureID" });
            DropIndex("StudentLectures", new[] { "student_studentID" });
            DropIndex("StudentLevels", new[] { "studentID" });
            DropIndex("StudentLevels", new[] { "levelID" });
            DropIndex("StudentLevels", new[] { "level_levelID" });
            DropIndex("StudentLevels", new[] { "student_studentID" });
            DropIndex("StudentExams", new[] { "studentID" });
            DropIndex("StudentExams", new[] { "examID" });
            DropIndex("StudentExams", new[] { "exam_examID" });
            DropIndex("StudentExams", new[] { "student_studentID" });
            DropIndex("StudentAssignments", new[] { "studentID" });
            DropIndex("StudentAssignments", new[] { "assignmentID" });
            DropIndex("StudentAssignments", new[] { "assignment_assignmentID" });
            DropIndex("StudentAssignments", new[] { "student_studentID" });
            DropForeignKey("CourseAchievement1", "Achievement_achievementID", "Achievements");
            DropForeignKey("CourseAchievement1", "Course_courseID", "Courses");
            DropForeignKey("StudentCourse1", "Course_courseID", "Courses");
            DropForeignKey("StudentCourse1", "Student_studentID", "Students");
            DropForeignKey("CourseAchievements", "achievementID", "Achievements");
            DropForeignKey("CourseAchievements", "courseID", "Courses");
            DropForeignKey("CourseAchievements", "achievement_achievementID", "Achievements");
            DropForeignKey("CourseAchievements", "course_courseID", "Courses");
            DropForeignKey("AchievementCourseStudents", "achievementID", "Achievements");
            DropForeignKey("AchievementCourseStudents", "courseID", "Courses");
            DropForeignKey("AchievementCourseStudents", "studentID", "Students");
            DropForeignKey("AchievementCourseStudents", "student_studentID", "Students");
            DropForeignKey("AchievementCourseStudents", "course_courseID", "Courses");
            DropForeignKey("AchievementCourseStudents", "achievement_achievementID", "Achievements");
            DropForeignKey("StudentCourses", "courseID", "Courses");
            DropForeignKey("StudentCourses", "studentID", "Students");
            DropForeignKey("StudentCourses", "course_courseID", "Courses");
            DropForeignKey("StudentCourses", "student_studentID", "Students");
            DropForeignKey("StudentLectures", "studentID", "Students");
            DropForeignKey("StudentLectures", "lectureID", "Lectures");
            DropForeignKey("StudentLectures", "lecture_lectureID", "Lectures");
            DropForeignKey("StudentLectures", "student_studentID", "Students");
            DropForeignKey("StudentLevels", "studentID", "Students");
            DropForeignKey("StudentLevels", "levelID", "Levels");
            DropForeignKey("StudentLevels", "level_levelID", "Levels");
            DropForeignKey("StudentLevels", "student_studentID", "Students");
            DropForeignKey("StudentExams", "studentID", "Students");
            DropForeignKey("StudentExams", "examID", "Exams");
            DropForeignKey("StudentExams", "exam_examID", "Exams");
            DropForeignKey("StudentExams", "student_studentID", "Students");
            DropForeignKey("StudentAssignments", "studentID", "Students");
            DropForeignKey("StudentAssignments", "assignmentID", "Assignments");
            DropForeignKey("StudentAssignments", "assignment_assignmentID", "Assignments");
            DropForeignKey("StudentAssignments", "student_studentID", "Students");
            DropPrimaryKey("CourseAchievements", new[] { "courseID", "achievementID" });
            AddPrimaryKey("CourseAchievements", new[] { "Course_courseID", "Achievement_achievementID" });
            DropPrimaryKey("StudentCourses", new[] { "studentID", "courseID" });
            AddPrimaryKey("StudentCourses", new[] { "Student_studentID", "Course_courseID" });
            AlterColumn("CourseAchievements", "Achievement_achievementID", c => c.Int(nullable: false));
            AlterColumn("CourseAchievements", "Course_courseID", c => c.Int(nullable: false));
            AlterColumn("StudentCourses", "Course_courseID", c => c.Int(nullable: false));
            AlterColumn("StudentCourses", "Student_studentID", c => c.Int(nullable: false));
            DropColumn("CourseAchievements", "achievementID");
            DropColumn("CourseAchievements", "courseID");
            DropColumn("StudentCourses", "studentXP");
            DropColumn("StudentCourses", "courseID");
            DropColumn("StudentCourses", "studentID");
            DropColumn("Courses", "numTeachers");
            DropColumn("Courses", "numStudents");
            DropColumn("Teachers", "userNameID");
            DropColumn("Teachers", "selected");
            DropTable("CourseAchievement1");
            DropTable("StudentCourse1");
            DropTable("AchievementCourseStudents");
            DropTable("StudentLectures");
            DropTable("StudentLevels");
            DropTable("StudentExams");
            DropTable("StudentAssignments");
            CreateIndex("CourseAchievements", "Achievement_achievementID");
            CreateIndex("CourseAchievements", "Course_courseID");
            CreateIndex("StudentCourses", "Course_courseID");
            CreateIndex("StudentCourses", "Student_studentID");
            AddForeignKey("CourseAchievements", "Achievement_achievementID", "Achievements", "achievementID", cascadeDelete: true);
            AddForeignKey("CourseAchievements", "Course_courseID", "Courses", "courseID", cascadeDelete: true);
            AddForeignKey("StudentCourses", "Course_courseID", "Courses", "courseID", cascadeDelete: true);
            AddForeignKey("StudentCourses", "Student_studentID", "Students", "studentID", cascadeDelete: true);
        }
    }
}
